import Vue from 'vue'
import VueRouter from 'vue-router'
import home from '../views/home/home.vue';
import vuex from 'vuex';
import store from '../store/index';

Vue.use(VueRouter)

const routes = [

    { path: '/home', component: home },
    { path: '/search', component: () => import("../views/search/search.vue") },
    { path: '/cart', component: () => import("../views/cart/cart.vue") },
    { path: '/profit', component: () => import("../views/profit/profit.vue") },
    { path: '', redirect: "/home" },
    { path: '/address', component: () => import("../components/address.vue") },
    { path: '/city', component: () => import("../views/home/city.vue") },
    { path: '/shopdetail', component: () => import("../views/home/shopdetail..vue") },


]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})



// router.beforeEach((to, from, next) => {

//     var auth = ["/home", "/search", "/cart", "/profit"]
//     if (auth.includes(to.fullPath)) {
//         if (store.state.cityid === "") {
//             next("/address")
//             return
//         }
//     }
//     next()

// })
export default router
